##################################################
# Makefile
##################################################

BOOT := boot.asm
KERNEL := kernel.asm
APP := app.asm

BOOT_BIN:=$(subst .asm,.bin,$(BOOT))
KERNEL_BIN:=$(subst .asm,.bin,$(KERNEL))
APP_BIN:=$(subst .asm,.bin,$(APP))


IMG:=/Users/chenalbert/hd60M.img

compile: $(BOOT_BIN) $(KERNEL_BIN) $(APP_BIN)

write : $(BOOT_BIN) $(KERNEL_BIN) $(APP_BIN)

	dd if=$(BOOT_BIN) of=$(IMG) bs=512 count=1 conv=notrunc
	dd if=$(KERNEL_BIN) of=$(IMG) bs=512 count=2 seek=1 conv=notrunc
	#dd if=$(app_BIN) of=$(IMG) bs=512 count=20 seek=50 conv=notrunc

clean :
	rm -f $(BOOT_BIN) $(KERNEL_BIN) $(APP_BIN) *.o *.lst

$(BOOT_BIN) : $(BOOT)
	nasm -g -l boot.lst -f bin $< -o $@

$(KERNEL_BIN) : $(KERNEL)
	nasm -g -l kernel.lst -f bin $< -o $@

$(APP_BIN) : $(APP)
	nasm -g -l app.lst -f bin $< -o $@



